<?php
require('include/config.inc.php');

$mysqli = new mysqli($mysql_host, $mysql_user, $mysql_password, $mysql_base);

if (mysqli_connect_errno()) {
    printf("Échec de la connexion : %s\n", mysqli_connect_error());
    exit();
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
        <head>
                <title>APRIA ACL VIEWER BETA 0.1</title>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
                <meta http-equiv="Content-Style-Type" content="text/css" />
                <meta http-equiv="Content-Language" content="fr" />
                <link rel="stylesheet" type="text/css" href="themes/style.css" />
                <!-- <link rel="stylesheet" type="text/css" href="themes/style2.css" /> -->
                <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.13/themes/vader/jquery-ui.css" />

        </head>

        <body>

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js"></script>


<pre>
ACL VIEWER BETA 0.1
/!\ Le choix de la source pour le R75 affiche toute la règle !
2 firewalls disponible : FWSM (firewall Interne) & R75 (firewall Internet)
Consulter le <a href="README.html">README</a>
</pre>

<table border="0">		
<tr>
<td>
		<form action="display.php" method ="POST">

<!-- CHOIX ACL -->
<label><strike>Sélectionnez l'access-list (Cisco ONLY)</strike>
<datalist id="ACL" hidden>
 <?php
$list = "SELECT distinct name FROM acl";
$result_list = $mysqli->query($list);
while ($row = $result_list->fetch_array(MYSQLI_ASSOC)) { 
    echo '<option value="'.$row["name"].'">'.$row["name"].'</option>';
	// echo '<br>';
}
?>
</datalist>

<td>
<!-- <input name="acl_name" datalist="ACL" multiple > -->
<script>
$('input:text[datalist][multiple]').each(function() {
    var elem = $(this),
        list = $(document.getElementById(elem.attr('datalist')));
    elem.autocomplete({
        source: list.children().map(function() {
            return $(this).text();
        }).get()
    });
});
</script>

</td>
</label>
<br>
</td>
</tr>

<tr>
<td>
<!-- CHOIX FIREWALL -->
<label><strike>Firewall</strike>
<datalist id="FIREWALL">
 <?php
$list = "SELECT distinct fw_name FROM acl";
$result_list = $mysqli->query($list);
while ($row = $result_list->fetch_array(MYSQLI_ASSOC)) { 
    echo '<option value="'.$row["fw_name"].'">'.$row["fw_name"].'</option>';
	echo '<br>';
}
?>
</datalist>
<td>
<!-- <input name="fw_name" datalist="FIREWALL" multiple > -->
<script>
$('input:text[datalist][multiple]').each(function() {
    var elem = $(this),
        list = $(document.getElementById(elem.attr('datalist')));
    elem.autocomplete({
        source: list.children().map(function() {
            return $(this).text();
        }).get()
    });
});
</script>
</td>
</label>
<br>
</td>
</tr>

<tr>
<td>
<!-- CHOIX SOURCE -->
<label>Sélectionnez la source
<datalist id="ACL_SRC">
<?php
$src_net = "SELECT distinct src_net FROM acl";
$result_src_net = $mysqli->query($src_net);
while ($row = $result_src_net->fetch_array(MYSQLI_ASSOC)) { 

    echo '<option value="'.$row["src_net"].'">'.$row["src_net"].'</option>';

	echo '<br>';
	
}
?>
</datalist>
<td>
  <input name="acl_src_net" datalist="ACL_SRC" multiple>
  <script>
$('input:text[datalist][multiple]').each(function() {
    var elem = $(this),
        list = $(document.getElementById(elem.attr('datalist')));
    elem.autocomplete({
        source: list.children().map(function() {
            return $(this).text();
        }).get()
    });
});
</script>
</td>
  </label>
</td>
</tr>

<tr>
<td>
<!-- CHOIX DESTINATION -->
<label>Sélectionnez la destination
<datalist id="ACL_DST">
<?php
$dst_net = "SELECT distinct dst_net FROM acl";
$result_dst_net = $mysqli->query($dst_net);
while ($row = $result_dst_net->fetch_array(MYSQLI_ASSOC)) { 

    echo '<option value="'.$row["dst_net"].'">'.$row["dst_net"].'</option>';

	echo '<br>';
	
}
?>
</datalist>
<td>
  <input name="acl_dst_net" datalist="ACL_DST" multiple>
    <script>
$('input:text[datalist][multiple]').each(function() {
    var elem = $(this),
        list = $(document.getElementById(elem.attr('datalist')));
    elem.autocomplete({
        source: list.children().map(function() {
            return $(this).text();
        }).get()
    });
});
</script>
</td>
  </label>
</td>
</tr>

<tr>
<td>
<input type="submit" value="Valider" />
</td>
</tr>
</form>

</table>
</body>
</html>